home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / lib / string / strnicmp.c < prev    next >
C/C++ Source or Header  |  1997-09-09  |  602b  |  41 lines

  1.  
  2. /*
  3.  *  STRNICMP.C
  4.  *
  5.  *    (c)Copyright 1992-1997 Obvious Implementations Corp.  Redistribution and
  6.  *    use is allowed under the terms of the DICE-LICENSE FILE,
  7.  *    DICE-LICENSE.TXT.
  8.  */
  9.  
  10. #include <string.h>
  11. #include <ctype.h>
  12.  
  13. #ifndef HYPER
  14. #define HYPER(x) x
  15. #endif
  16.  
  17. typedef unsigned char ubyte;
  18.  
  19. int
  20. HYPER(strnicmp)(s, d, n)
  21. const char *s;
  22. const char *d;
  23. int n;
  24. {
  25.     ubyte c;
  26.  
  27.     if (n == 0)
  28.     return(0);
  29.  
  30.     while (tolower(c = *s) == tolower(*(ubyte *)d)) {
  31.     if (c == 0 || --n == 0)
  32.         return(0);
  33.     ++s;
  34.     ++d;
  35.     }
  36.     if (tolower(c) < tolower(*(ubyte *)d))
  37.     return(-1);
  38.     return(1);
  39. }
  40.  
  41.